package com.Txunda.fxw.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.Txunda.fxw.R;
import com.bumptech.glide.Glide;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.List;
import java.util.Map;
/**
 * ��ҳ���adapter
 * @author Administrator
 *
 */
public class IndexTeaAdapter extends BaseAdapter{

	private Context mContext;
	private List<Map<String,String>>list_data;

	public IndexTeaAdapter(Context context,List<Map<String,String>>list_data){
		this.mContext = context;
		this.list_data = list_data;
	}
	@Override
	public int getCount() {
		int ret = 0;
		if(list_data != null){
			ret = list_data.size();
		}
		return ret;
	}

	@Override
	public Object getItem(int position) {
		return list_data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		MyViewHolder vh;
		if(convertView == null){
			convertView = LayoutInflater.from(mContext).inflate(R.layout.item_index,null);
			vh =new MyViewHolder();
			ViewUtils.inject(vh,convertView);
			convertView.setTag(vh);
		}else{
			vh = (MyViewHolder) convertView.getTag();
		}
		
		
		String ad_pic = list_data.get(position).get("ad_pic");
//		imageLoader.disPlay(vh.item_img, ad_pic);
		Glide.with(mContext).load(ad_pic).into(vh.item_img);
		
		return convertView;
	}
	public class MyViewHolder{
		@ViewInject(R.id.item_img)
		private ImageView item_img;
		@ViewInject(R.id.linear_list)
		private LinearLayout linear_list;
	}

}
